package com.winning.devops.demo.base.disruptor;

import com.lmax.disruptor.EventHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Component;

/**
 * @author chensj
 * @title 日志获取后的处理
 * @project logback-demo
 * @package com.winning.devops.demo.base.disruptor
 * @date: 2019-04-09 16:08
 */
@Component
public class LoggerEventHandler implements EventHandler<LoggerEvent> {
    @Autowired
    private SimpMessagingTemplate simpMessagingTemplate;
    @Override
    public void onEvent(LoggerEvent loggerEvent, long l, boolean b) throws Exception {
        // 推送日志到/topic/pullLogger主题
        simpMessagingTemplate.convertAndSend("/topic/pullLogger",loggerEvent.getLogger());
    }
}
